package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.PlanExchange;
import com.indusfo.spc.service.PlanExchangeService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author: 熊冰
 * @Date: 2019/11/11 10:29
 * 任务单维修工序
 */

@Controller
@RequestMapping("/planExchange")
public class PlanExchangeController {
	@Autowired
	private PlanExchangeService planExchangeService;

	//查询
	@RequestMapping(value="/queryPlanExchange")
	@ResponseBody
	public JSONObject queryPlanExchange(PlanExchange planExchange) {
		JSONObject json = planExchangeService.queryPlanExchange(planExchange);
		return json;
	}

	//新增
	@RequestMapping(value="/insertPlanExchange", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject insertPlanExchange(PlanExchange planExchange) {
		JSONObject json = planExchangeService.insertPlanExchange(planExchange);
		return json;
	}

	//修改
	@RequestMapping(value = "/updatePlanExchange",method= RequestMethod.POST)
	@ResponseBody
	public JSONObject updatePlanExchange (PlanExchange planExchange){
		JSONObject json=planExchangeService.updatePlanExchange(planExchange);
		return json;
	}

	//删除
	@RequestMapping(value="/deletePlanExchange", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject deletePlanExchange(@RequestParam("planExchangeIds") List<Integer> planExchangeIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planExchangeService.deletePlanExchange(planExchangeIds, dataState);
		return json;
	}

	//启用
	@RequestMapping(value="/startPlanExchange", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject startPlanExchange(@RequestParam("planExchangeIds") List<Integer> planExchangeIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planExchangeService.deletePlanExchange(planExchangeIds, dataState);
		return json;
	}

	//停用
	@RequestMapping(value="/stopPlanExchange", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject stopPlanExchange(@RequestParam("planExchangeIds") List<Integer> planExchangeIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planExchangeService.deletePlanExchange(planExchangeIds, dataState);
		return json;
	}





}
